package com.example.skytakeoutserver.data.entity

import com.fasterxml.jackson.annotation.JsonFormat
import io.swagger.v3.oas.annotations.media.Schema
import lombok.AllArgsConstructor
import lombok.Builder
import lombok.Data
import lombok.Getter
import lombok.NoArgsConstructor
import lombok.Setter
import org.springframework.data.annotation.Id
import org.springframework.data.relational.core.mapping.Table
import java.math.BigDecimal
import java.time.Instant

/**
 * 所有数据库表
 */

@Table("shopping_cart")
@Data
@NoArgsConstructor
@Schema(title = "购物车实体 ShoppingCart")
data class ShoppingCart(
    @Id
    var id: Long? = null,
    @Schema(description = "名称")
    var name: String? = null,
    //用户id
    @Schema(description = "用户id")
    var userId: Long? = null,
    //菜品id
    @Schema(description = "菜品id")
    var dishId: Long? = null,
    //套餐id
    @Schema(description = "套餐id")
    var setmealId: Long? = null,
    //数量
    @Schema(description = "数量")
    var number: Int? = null,
    //菜品价格
    @Schema(description = "金额")
    var amount: BigDecimal? = null,
    //口味
    @Schema(description = "口味")
    var dishFlavor: String? = null,
    //描述信息
    @Schema(description = "图片")
    var image: String? = null,

    //创建时间
    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-6")
    var createTime: Instant? = null
)

@Table("setmeal_dish")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(title = "套餐菜品关系 SetmealDish")
data class SetmealDish(

    @Id
    var id: Long? = null,
    //套餐id
    @Schema(description = "套餐id")
    var setmealId: Long? = null,
    //菜品id
    @Schema(description = "菜品id")
    var dishId: Long? = null,
    @Schema(description = "菜品名")
    var name: String? = null,
    @Schema(description = "菜品价格")
    var price: BigDecimal? = null,
    @Schema(description = "份数")
    var copies: Int? = null
)

@Table("setmeal")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(title = "口味实体 Setmeal")
data class Setmeal(
    @Id
    var id: Long? = null,
    @Schema(description = "菜品名")
    var name: String? = null,
    //菜品分类id
    @Schema(description = "菜品分类id")
    var categoryId: Long? = null,
    //菜品价格
    @Schema(description = "菜品价格")
    var price: BigDecimal? = null,
    //图片
    @Schema(description = "图片")
    var image: String? = null,
    //描述信息
    @Schema(description = "描述信息")
    var description: String? = null,
    //0 停售 1 起售
    @Schema(description = "0 停售 1 起售")
    var status: Int? = null,
    //创建时间
    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-6")
    var createTime: Instant? = null,
    //更新时间
    @Schema(description = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-6")
    var updateTime: Instant? = null,
    //创建人
    @Schema(description = "创建人")
    var createUser: Long? = null,
    //修改人
    @Schema(description = "修改人")
    var updateUser: Long? = null
)


@Table("orders")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(title = "订单实体 Orders")
data class Orders(
    @Id
    var id: Long? = null,
    @Schema(description = "订单号")
    var number: String? = null,
    @Schema(description = "订单状态 1待付款 2待接单 3已接单 4派送中 5已完成 6已取消 7退款")
    var status: Int? = null,
    @Schema(description = "下单用户id")
    var userId: Long? = null,
    @Schema(description = "地址id")
    var addressBookId: Long? = null,
    @Schema(description = "支付状态 0未支付 1已支付 2退款")
    var payStatus: Int? = null,
    @Schema(description = "支付方式 1微信，2支付宝")
    var payMethod: Int? = null,
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-6")
    @Schema(description = "下单时间")
    var orderTime: Instant? = null,
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-6")
    @Schema(description = "结账时间")
    var checkoutTime: Instant? = null,
    @Schema(description = "实收金额")
    var amount: BigDecimal? = null,
    @Schema(description = "备注")
    var remark: String? = null,
    @Schema(description = "用户名")
    var userName: String? = null,
    @Schema(description = "phone")
    var phone: String? = null,
    @Schema(description = "地址")
    var address: String? = null,
    @Schema(description = "收货人")
    var consignee: String? = null,
    @Schema(description = "订单取消原因")
    var cancelReason: String? = null,
    @Schema(description = "订单拒绝原因")
    var rejectionReason: String? = null,
    @Schema(description = "订单取消时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-6")
    var cancelTime: Instant? = null,
    @Schema(description = "预计送达时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    var estimatedDeliveryTime: Instant? = null,
    @Schema(description = "配送状态  1立即送出  0选择具体时间")
    var deliveryStatus: Int? = null,
    @Schema(description = "送达时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-6")
    var deliveryTime: Instant? = null,
    @Schema(description = "打包费")
    var packAmount: Int? = null,
    @Schema(description = "餐具数量")
    var tablewareNumber: Int? = null,
    @Schema(description = "餐具数量状态  1按餐量提供  0选择具体数量")
    var tablewareStatus: Int? = null,
)


@Table("user")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Schema(title = "用户")
data class User(
    @Id
    var id: Long? = null,
    @Schema(description = "姓名")
    var name: String? = null,
    @Schema(description = "手机号")
    var phone: String? = null,
    @Schema(description = "微信用户唯一标识")
    var openid: String? = null,
    @Schema(description = "性别 0 女 1 男")
    var sex: String? = null,
    @Schema(description = "份证号")
    var idNumber: String? = null,
    @Schema(description = "头像")
    var avatar: String? = null,
    @Schema(description = "注册时间")
    var createTime: Instant? = null
)


@Table("employee")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Schema(title = "员工")
data class Employee(
    @Id
    val id: Long? = null,
    @Schema(description = "姓名")
    val name: String? = null,

    @Schema(description = "用户名")
    val username: String? = null,

    @Schema(description = "手机号")
    val phone: String? = null,

    @Schema(description = "性别 0 女 1 男")
    val sex: String? = null,

    @Schema(description = "身份证号")
    val idNumber: String? = null,

    @Schema(description = "注册时间", pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-6")
    var createTime: Instant? = null,

    @Schema(description = "更新时间", pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-6")
    var updateTime: Instant? = null,

    @Schema(description = "状态")
    var status: Int? = null,

    @Schema(description = "密码")
    var password: String? = null
)


@Table(name = "dish_flavor")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Schema(title = "口味")
data class DishFlavor(
    @Id
    var id: Long,
    @Schema(description = "菜品id")
    var dishId: Long,
    @Schema(description = "口味名称")
    var name: String,
    @Schema(description = "口味数据")
    var value: String,
)


@Table("dish")
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(title = "菜品")
data class Dish(

    @Id
    var id: Long? = null,
    @Schema(description = "菜品名")
    var name: String? = null,
    //菜品分类id
    @Schema(description = "菜品分类id")
    var categoryId: Long? = null,
    //菜品价格
    @Schema(description = "菜品价格")
    var price: BigDecimal? = null,
    //图片
    @Schema(description = "图片")
    var image: String? = null,
    //描述信息
    @Schema(description = "描述信息")
    var description: String? = null,
    //0 停售 1 起售
    @Schema(description = "0 停售 1 起售")
    var status: Int? = null,
    //创建时间
    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-6")
    var createTime: Instant? = null,
    //更新时间
    @Schema(description = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT-6")
    var updateTime: Instant? = null,
    //创建人
    @Schema(description = "创建人")
    var createUser: Long? = null,
    //修改人
    @Schema(description = "修改人")
    var updateUser: Long? = null
)


@Table("address_book")
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(title = "通讯录")
data class AddressBook(
    @Id
    var id: Long? = null,
    // 修改人
    @Schema(description = "用户id")
    var userId: Long? = null,

    @Schema(description = "收货人")
    var consignee: Long? = null,

    @Schema(description = "手机号")
    var phone: String? = null,

    @Schema(description = "性别, 0为女，1为男")
    var sex: String? = null,

    @Schema(description = "省级区划编号")
    var provinceCode: String? = null,

    @Schema(description = "省级名")
    var provinceName: String? = null,

    @Schema(description = "市级区划编号")
    var cityCode: String? = null,

    @Schema(description = "市名称")
    var cityName: String? = null,


    //区级区划编号
    @Schema(description = "区级区划编号")
    var districtCode: String? = null,

    //区级名称
    @Schema(description = "区级名称")
    var districtName: String? = null,

    //详细地址
    @Schema(description = "详细地址")
    var detail: String? = null,

    //标签
    @Schema(description = "标签")
    var label: String? = null,

    //是否默认 0否 1是
    @Schema(description = "是否默认 0否 1是")
    var isDefault: Int? = null
)


@Table("category")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Schema(title = "分类")
data class Category(
    @Id
    var id: Long? = null,

    @Schema(description = "类型, 1为菜品分类，2为套餐分类")
    var type: Int? = null,

    @Schema(description = "分类名称")
    var name: String? = null,

    @Schema(description = "顺序")
    var sort: Int? = null,

    @Schema(description = "分类状态, 0标识禁用，1表示启用")
    var status: Int? = null,

    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "GMT+8")
    var createTime: Instant? = null,

    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "GMT+8")
    var updateTime: Instant? = null,

    var createUser: Long? = null,

    var updateUser: Long? = null,
)

@Table("order_detail")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(title = "订单详情")
data class OrderDetail(
    @Id
    var id: Long? = null,

    @Schema(description = "数量")
    var number: Int? = null,

    @Schema(description = "名称")
    var name: String? = null,

    @Schema(description = "订单id")
    var orderId: Long? = null,

    @Schema(description = "菜品id")
    var dishId: Long? = null,

    @Schema(description = "套餐id")
    var setmealId: Int? = null,

    @Schema(description = "口味")
    var dishFlavor: String? = null,

    @Schema(description = "实收金额")
    var amount: BigDecimal? = null,

    @Schema(description = "图片")
    var image: String? = null

)